<template>
  <div id="app">
    <el-cascader
        size="mini"
        :options="options"
        v-model="selectedOptions"
        @change="handleChange">
    </el-cascader>
  </div>
</template>

<script>
import {regionData, CodeToText} from 'element-china-area-data'

export default {
  name: 'Area',
  components: {},
  props: {},
  data() {
    return {
      options: regionData,
      selectedOptions: [],
      addtions: {},			//存储地址数据
      name: ''
    }
  },
  methods: {
    handleChange() {
      this.name = ''
      //我们选择地址后，selectedOptions 会保存对应的区域码，例如北京的区域码为'110000'
      //selectedOptions是区域码组成的数组
      //我们要取出区域码对应的汉字，就需要用CodeToText(区域码)进行输出
      // this.addtions.selectedOptions = value
      //把每个区域码转化为地区拼接到name
      this.selectedOptions.map(item => this.name += CodeToText[item] + '/')
      // this.addtions.names = this.name
      this.$emit('getArea', this.name)
    },
    getMsg(msg){
      console.log(msg)
    }
  }
}
</script>

<style lang="less">

</style>

